package ui;

import config.GameConfig;

import javax.swing.*;
import java.awt.*;

public class LayerPoint extends Layer {
    /**
     * 分数最大位数
     */

    private static final int POINT_BIT = 5;
    /**
     * 升级行数
     */
    private static final int LEVEL_UP = GameConfig.getSystemConfig().getLevelUp();


    /**
     * 消行y坐标
     */
    private  final int rmlineY;
    /**
     *分数y坐标
     */
    private  final int pointY;
    /**
     *经验值y坐标
     */
    private final int expY;
    /**
     *消行x坐标
     */
    private final int comX;


    public LayerPoint(int x, int y, int w, int h) {
        super(x, y, w, h);
        //初始化共通的X坐标
        this.comX = this.w - IMG_NUMBER_W * POINT_BIT - PADDING;
        //初始化分数显示的Y坐标
        this.pointY=PADDING;
        //初始化消行显示的Y坐标
        this.rmlineY=this.pointY + Img.RMLINE.getHeight(null) + PADDING;
        //经验值的y坐标
        this.expY=this.pointY +Img.RMLINE.getHeight(null)+PADDING+50;
    }

    @Override
    public void paint(Graphics g){
        this.createWindow(g);
        //窗口标题（分数）
        g.drawImage(Img.POINT,this.x + pointY,this.y+pointY,null);
        //显示分数
        this.drawNumberLeftPad(comX,pointY,this.dto.getNowPoint(),POINT_BIT,g);
        //窗口标题（消行）
        g.drawImage(Img.RMLINE,this.x + PADDING,this.y + rmlineY,null);
        //显示消行
        this.drawNumberLeftPad(comX,rmlineY,this.dto.getNowRemoveLine(),POINT_BIT,g);
        //绘制值槽(经验值)
        int rmLine =this.dto.getNowRemoveLine();
        this.drawRect(expY,"下一级",null,(double)(rmLine % LEVEL_UP)/(double)LEVEL_UP,g);
    }
}
